home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / SYS / s / smconfig < prev    next >
Text File  |  1996-09-26  |  4KB  |  155 lines

  1. /*
  2.  * Config ShadowMaster via it's Rexx port...
  3.  *
  4.  * Copyright 1991, Mike Meyer
  5.  * All Rights Reserved
  6.  *
  7.  * See the file "ShadowMaster:Distribution" for information on distribution.
  8.  */
  9. options results
  10. address SHADOWMASTER
  11.  
  12. /* Make sure we got tools we need to do the job */
  13. if ~show('Libraries', 'rexxarplib.library') then
  14.     if ~addlib('rexxarplib.library', 0, -30) then do
  15.         say "Can't find rexxarplib.library"
  16.         exit 10
  17.         end
  18.  
  19. if ~show('Libraries', 'rexxsupport.library') then
  20.     if ~addlib('rexxsupport.library', 0, -30) then do
  21.         say "Can't find rexxsupport.library"
  22.         exit 10
  23.         end
  24.  
  25. /* Make sure there's a running ShadowMaster */
  26. if ~show('Ports', 'SHADOWMASTER') then do
  27.     say "Can't configure a ShadowMaster that isn't running"
  28.     exit 10
  29.     end
  30.  
  31. /* If we're not already running, set up my host and port */
  32. if showlist('Ports', SMCONFIGPORT) | showlist('Ports', SMCONFIGHOST) then exit
  33. address AREXX '"call createhost SMCONFIGHOST, SMCONFIGPORT"'
  34. call openport SMCONFIGPORT
  35. address command "waitforport SMCONFIGHOST"
  36.  
  37. /* Make sure we clean up if there's a problem (old versoin of RexxArpLib */
  38. signal on syntax
  39. signal on error
  40.  
  41. /* Create the world */
  42. call OpenWindow SMCONFIGHOST, 0, 11, 350, 60, ,
  43.     'CLOSEWINDOW+GADGETUP', 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH', ,
  44.     'Screen Saver Configuration'
  45.  
  46. /* The String Gadgets */
  47. Call SetAPen SMCONFIGHOST, 1
  48. Call Move SMCONFIGHOST, 10, 27
  49. Call Text SMCONFIGHOST, "Command"
  50. Call AddGadget SMCONFIGHOST, 75, 20, "COMMAND", "", '%d%1%g', 255, RIDGEBORDER
  51. Call Move SMCONFIGHOST, 10, 45
  52. Call Text SMCONFIGHOST, "Seconds"
  53. Call AddGadget SMCONFIGHOST, 75, 38, "SECONDS", "", '%d%1%g', 45, RIDGEBORDER
  54. Call AddGadget SMCONFIGHOST, 130, 37, "CONFIG", "Config", '%d'
  55. Call AddGadget SMCONFIGHOST, 190, 37, "BLANK", "Blank", '%d'
  56. Call AddGadget SMCONFIGHOST, 242, 37, "QUIT", "Quit", '%d'
  57. Call AddGadget SMCONFIGHOST, 300, 37, "USE", "Use", '%d'
  58.  
  59. /* Get the state of the world, and put it in old */
  60. call saverstate
  61. old.command = new.command
  62. old.seconds = new.seconds
  63. old.blanker = new.blanker
  64. old.args = new.args
  65.  
  66. do forever
  67.     call waitpkt SMCONFIGPORT
  68.     do forever
  69.         pkt = getpkt(SMCONFIGPORT)
  70.         if c2d(pkt) = 0 then leave
  71.         gadget = getarg(pkt, 0)
  72.         select
  73.             when gadget = "CLOSEWINDOW" then signal cancel
  74.             when gadget = "BLANK" then 'blank'
  75.             when gadget = "USE" then do
  76.                 call windowstate
  77.                 signal use
  78.                 end
  79.             when gadget = "QUIT" then do
  80.                 'quit'
  81.                 signal use
  82.                 end
  83.             when gadget = "CONFIG" then do
  84. /* Now nonfunctional...
  85.                 call windowstate
  86.                 address command new.blanker'-config'
  87.                 call saverstate
  88. */                end
  89.             when gadget = "COMMAND" then do
  90.                 new.command =  getarg(pkt, 1)
  91.                 'command' new.command
  92.                 call fixcommand
  93.                 end
  94.             when gadget = "SECONDS" then do
  95.                 new.seconds = getarg(pkt, 1)
  96.                 'seconds' new.seconds
  97.                 end
  98.             otherwise nop
  99.             end
  100.         end
  101.     end
  102.  
  103. exit
  104.  
  105. cancel:
  106.     'command' old.command
  107.     'seconds' old.seconds
  108. error:
  109. syntax:
  110. use:
  111.     call closewindow SMCONFIGHOST
  112.     call closeport SMCONFIGPORT
  113.     exit
  114.  
  115. /* saverstate - makes the world confirm to what the saver thinks it is */
  116. saverstate: procedure expose new.
  117.     'command'
  118.     new.command = result
  119.     call fixcommand
  120.     call RemoveGadget SMCONFIGHOST, "COMMAND"
  121.     call AddGadget SMCONFIGHOST, 75, 20, "COMMAND", new.command, '%d%1%g', 255, RIDGEBORDER
  122.  
  123.     'seconds'
  124.     new.seconds = result
  125.     call RemoveGadget SMCONFIGHOST, "SECONDS"
  126.     call AddGadget SMCONFIGHOST, 75, 38, "SECONDS", new.seconds, '%d%1%g', 45, RIDGEBORDER
  127.     return
  128.  
  129. /* windowstate - makes the world confirm to whats in the window. */
  130. windowstate: procedure expose new.
  131.  
  132.     /* Command gadget */
  133.     call ReadGadget SMCONFIGHOST, "COMMAND"
  134.     call waitpkt SMCONFIGPORT
  135.     pkt = getpkt(SMCONFIGPORT)
  136.     if getarg(pkt, 0) ~= "COMMAND" then exit 20
  137.     new.command = getarg(pkt, 1)
  138.     'command' new.command
  139.     call fixcommand
  140.  
  141.     /* Seconds gadget */
  142.     call ReadGadget SMCONFIGHOST, "SECONDS"
  143.     call waitpkt SMCONFIGPORT
  144.     pkt = getpkt(SMCONFIGPORT)
  145.     if getarg(pkt, 0) ~= "SECONDS" then exit 20
  146.     new.seconds = getarg(pkt, 1)
  147.     'seconds' new.seconds
  148.     return
  149.  
  150. /* fixcommand - given new.command, set new.blanker and new.args */
  151. fixcommand: procedure expose new.
  152.     parse value new.command with new.blanker new.args
  153.     new.args = strip(new.args)
  154.     if new.command == "" then new.blanker = "ShadowMaster:savers/"
  155.